home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / ACORNUSERS / EMULATOR / GAMEBOY / !Gameboy / infos / MANUAL next >
Text File  |  1995-01-28  |  36KB  |  1,063 lines

  1.  
  2.  
  3. ==============================================================================
  4.             Everything You Always Wanted To Know About GAME BOY *
  5. ==============================================================================
  6.  
  7.                         * but were afraid to ask
  8.  
  9.  
  10.                       Written by Dr. -Pan-/Anthrox
  11.  
  12.  Forward: The following was typed up for informational purposes regarding
  13.           the inner workings on the hand-held game machine known as
  14.           Game Boy, manufactured and designed by Nintendo Co., LTD.
  15.           All files found in this package are presented to inform
  16.           a user on how their Game Boy works and what makes it "tick".
  17.           Game Boy is copyrighted by Nintendo Co., LTD.
  18.           Any reference to copyrighted material is not presented
  19.           for monetary gain, but for educational purposes and higher
  20.           learning.
  21.  
  22.  
  23.           If you do not ask, you will not know - -Pan-/ATX
  24.           No askie, no learnie - someone must've said this...
  25.  
  26. 1. What are the Game Boy's true specs?
  27.    -----------------------------------
  28.  
  29.  The Game Boy really is a powerful machine! FAQ files on Game Boy can be
  30.  found on many Internet sites. Most FAQs contains wrong information.
  31.  Such as claiming it only has 8 sprites.  Here are the correct facts:
  32.  
  33.  The Game Boy uses a custom/updated/or modified Z80 processor. Comparing
  34.  the Game Boy's Z80 instruction set with a book on the Z80 (circa 1982)
  35.  shows that the GB Z80 has a few different instructions. Such as
  36.  LD (HLI),#$xx
  37.  LD (HLD),#$xx
  38.  SWAP A through L
  39.  LD A,($xx)
  40.  
  41.  Screen Size: Physical screen: 160*144  VRAM screen image: 256*256
  42.  Screen scrolling is wrap around type; when a part of the image is off the
  43.  screen it will be shown on the opposite side of the screen.
  44.  
  45.  Although the screen can contain 1024 tiles, only 256 of them may be UNIQUE.
  46.  Each tile may have up to 4 colors. You may change the color of the pixel
  47.  value.  There are 4 shades of gray. You can select which shade you want
  48.  for that pixel value. However, when you change the color for that pixel value
  49.  EVERY tile that has a pixel with the same value will also be affected.
  50.  This is good for a routine which fades out the screen or performs a GLOWING
  51.  effect of some kind.
  52.  The tile graphics are 8*8 pixels, each pixel contains 2 bits of data to
  53.  create 4 numbers. Each number is the color value for that pixel.
  54.  The graphics are stored as as bitmapped tiles much like the SNES.
  55.  This is the confusing part for me. It is either like the
  56.  4 color SNES tile or it is INTERLEAVED.
  57.  
  58.  SNES 4 Color Tile: A            INTERLEAVED 4 Color Tile: A
  59.  
  60.  .11111..                         .11111..   <- first plane
  61.  11...11.                         ........   <- second plane
  62.  11...11.                         11...11.
  63.  1111111.  <- first plane         ........
  64.  11...11.                         11...11.
  65.  11...11.                         ........
  66.  11...11.                         1111111.   <- first plane
  67.  ........                         ........   <- second plane
  68.  
  69.  ........                         11...11.
  70.  ........                         ........
  71.  ........                         11...11.
  72.  ........                         ........
  73.  ........  <- second plane        11...11.
  74.  ........                         ........
  75.  ........                         ........
  76.  ........                         ........
  77.  
  78.  You'll have to figure it out by yourself since I haven't gotten into it :)
  79.  
  80.  Graphics vram location for OBJ and BG tiles start at $8000 and end at $97FF
  81.  
  82.  
  83.  
  84.  Sprites: 40 Sprites! They may be 8*8 or 8*16.
  85.  
  86.  Each sprite has up to 4 colors. There are 2 palettes to chose from
  87.  
  88.  The sprites can be flipped on the X and/or Y axis
  89.  
  90.  Sprite OAM ram:  Location: $FE00->$FE9F
  91.  
  92.  Each sprite data contains 4 bytes of info. They are:
  93.  
  94.  Byte 1: Y screen position; 8 bits
  95.  Byte 2: X screen position; 8 bits
  96.  Byte 3: Character code; tile number $00-$FF
  97.  Byte 4: Palette, X, Y, Priority; Most Significant 4 bits.
  98.          First 4 bits are NOT USED!
  99.  
  100.          Bit 7 - Priority
  101.          Bit 6 - Y flip
  102.          Bit 5 - X flip
  103.          Bit 4 - Palette number; 0,1
  104.          Bit 3-0 - NOT USED!
  105.  
  106.  Display Ram size: 64k bit
  107.  Work Ram size: 64k bit
  108.  
  109.  There are 2 Memory Bank Controllers (MBC) that can be used. MBC1 is the
  110.  standard that is used on most cartridges.
  111.  MBC2 is used with cartridges which need Save-Ram.
  112.  It controls extended Save-RAM banks.
  113.  
  114.  Extended Ram may go up to 256k bit.
  115.  
  116.  MBC1 - When controlling ROM only you may read up to 16 megabits! (2 MBYTES)
  117.         When controlling RAM only you may read up to 4 megabits (512 kbytes)
  118.                                       and read up to 256kbit RAM
  119.  
  120.  MBC2 - Controls Back-Up Ram (Save-RAM) (512 * 4 bit) which can be extended
  121.         to 2 megabits (16 kbyte * 16)  256k byte
  122.  
  123.  Sound: There are only 2 channels; left and right.
  124.         But there are 4 different ways to produce sound:
  125.         Sound 1: produces quadrangular wave patterns with sweep and envelope
  126.                  functions
  127.         Sound 2: produces quadrangular wave patterns with envelope functions
  128.         Sound 3: produces a voluntary wave pattern (samples can be possible
  129.                                                     if done right)
  130.         Sound 4: produces white noise
  131.  
  132.         You tell the channel which sound number you want to use and it
  133.         will produce the sound when you've set the according data.
  134.  
  135.         Since I'm not a sound programmer I really can't get into the details
  136.         of how to create waves patterns and such. It would confuse you more
  137.         than me!
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149. 2. The Game Boy seems like a nice little system! But what are the registers?
  150.    And what about the memory mapping?
  151.    -------------------------------------------------------------------------
  152.  
  153.    You can check out the memory mapping by viewing the 2 graphic diagrams
  154.    included with this informational tutorial. They are called:
  155.    Address1.IFF, Address1.PCX, Address2.IFF, Address2.PCX
  156.  
  157.    .IFF is for Amiga users.   .PCX is for PC users.
  158.  
  159.    They will display how the memory is mapped out and how banking works.
  160.  
  161.  
  162.    The registers:
  163.  
  164. ------------------------------------------------------------------------------
  165.    Address  - $FF00
  166.    Name     - P1
  167.    Contents - Register for reading joy pad info.    (R/W)
  168.  
  169.            Bit 7 - Not used
  170.            Bit 6 - Not used
  171.            Bit 5 - P15 out port
  172.            Bit 4 - P14 out port
  173.            Bit 3 - P13 in port
  174.            Bit 2 - P12 in port
  175.            Bit 1 - P11 in port
  176.            Bit 0 - P10 in port
  177.  
  178.          This is a very strange way of reading joypad info.
  179.          There are only 8 possible button/switches on the Game Boy.
  180.          A, B, Select, Start, Up, Down, Left, Right.
  181.          Why they made their joypad registers in this way I'll never know.
  182.          They could have used all 8 bits and you just read which one is on.
  183.  
  184.          This is the matrix layout for register $FF00:
  185.  
  186.  
  187.            P14                P15
  188.             |                  |
  189. --P10-------O-Right------------O-A---------
  190.             |                  |
  191. --P11-------O-Left-------------O-B---------
  192.             |                  |
  193. --P12-------O-Up---------------O-Select----
  194.             |                  |
  195. --P13-------O-Down-------------O-Start-----
  196.             |                  |
  197.  
  198.  
  199.           This is the logic in reading joy pad data:
  200.  
  201.           Turn on P15 (bit 5) in $ff00
  202.           Wait a few clock cycles
  203.           read $ff00 into A
  204.           invert A   - same as EOR #$FF - just reverse all bits
  205.                        apparently the joy pad info returned is like the C64
  206.                        info. 0 means on, 1 means off. But logic tells us
  207.                        that it should be the other way around. So to make it
  208.                        less confusing we just flip the bits!
  209.  
  210.           AND A with #$0F - get only the first four bits
  211.                             By turning on P15 we are trying to read column
  212.                             P15 in the matrix layout. It contains A,B,SEL,STRT
  213.  
  214.           SWAP A - #$3f becomes #$f3, it swaps hi<->lo nibbles
  215.  
  216.           store A in B for backup
  217.  
  218.  
  219.           Turn on P14 (bit 4) in $ff00
  220.           Wait a few more clock cycles
  221.           read $ff00 into A
  222.           invert A - just as above
  223.           AND A with #$0F - get first 4 bits
  224.                           - By turning on P14 we get the data for column P14
  225.                             in the matrix layout. It contains U,D,L,R
  226.  
  227.           OR A with B - put the two values together.
  228.  
  229.           turn on P14 and P15 in $ff00 to reset.
  230.  
  231.           The button values using the above method are such:
  232.           $80 - Start             $8 - Down
  233.           $40 - Select            $4 - Up
  234.           $20 - B                 $2 - Left
  235.           $10 - A                 $1 - Right
  236.  
  237.           Let's say we held down A, Start, and Up.
  238.           The value returned in accumulator A would be $94
  239.  
  240.  
  241.           Let's see this method in action!
  242.           Game: Ms. Pacman
  243.           Address: $3b1
  244.  
  245. 0003B1: 0003B1: 3E 20          LD A,#$20      <- bit 5 = $20
  246. 0003B3: 0003B3: EA 00 FF       LD ($FF00),A   <- turn on P15
  247. 0003B6: 0003B6: FA 00 FF       LD A,($FF00)
  248. 0003B9: 0003B9: FA 00 FF       LD A,($FF00)   <- wait a few cycles
  249. 0003BC: 0003BC: 2F             CPL            <- complement (invert) EOR #$ff
  250. 0003BD: 0003BD: E6 0F          AND #$0F       <- get only first 4 bits
  251. 0003BF: 0003BF: CB 37          SWAP A         <- swap it
  252. 0003C1: 0003C1: 47             LD B,A         <- store A in B
  253. 0003C2: 0003C2: 3E 10          LD A,#$10      <- bit 4 = $10
  254. 0003C4: 0003C4: EA 00 FF       LD ($FF00),A   <- turn on P14
  255. 0003C7: 0003C7: FA 00 FF       LD A,($FF00)
  256. 0003CA: 0003CA: FA 00 FF       LD A,($FF00)
  257. 0003CD: 0003CD: FA 00 FF       LD A,($FF00)
  258. 0003D0: 0003D0: FA 00 FF       LD A,($FF00)
  259. 0003D3: 0003D3: FA 00 FF       LD A,($FF00)
  260. 0003D6: 0003D6: FA 00 FF       LD A,($FF00)   <- Wait a few MORE cycles
  261. 0003D9: 0003D9: 2F             CPL            <- complement (invert)
  262. 0003DA: 0003DA: E6 0F          AND #$0F       <- get first 4 bits
  263. 0003DC: 0003DC: B0             OR B           <- put A and B together
  264.  
  265.  
  266.   The following routine is common on SNES as well. It clarifies that you've
  267.   only pressed the specified button(s) once every other frame. That way the
  268.   Joypad is less sensitive to wrong/bad/false movements.
  269.  
  270. 0003DD: 0003DD: 57             LD D,A         <- store A in D
  271. 0003DE: 0003DE: FA 8B FF       LD A,($FF8B)   <- read old joy data from ram
  272. 0003E1: 0003E1: AA             XOR D          <- toggle w/current button bit
  273. 0003E2: 0003E2: A2             AND D          <- get current button bit back
  274. 0003E3: 0003E3: EA 8C FF       LD ($FF8C),A   <- save in new Joydata storage
  275. 0003E6: 0003E6: 7A             LD A,D         <- put original value in A
  276. 0003E7: 0003E7: EA 8B FF       LD ($FF8B),A   <- store it as old joy data
  277.  
  278.  
  279.  
  280. 0003EA: 0003EA: 3E 30          LD A,#$30      <- turn on P14 and P15
  281. 0003EC: 0003EC: EA 00 FF       LD ($FF00),A   <- RESET Joypad?!
  282. 0003EF: 0003EF: C9             RET            <- Return from Subroutine
  283.  
  284. ------------------------------------------------------------------------------
  285.  
  286.    Address  - $FF01
  287.    Name     - SB
  288.    Contents - Serial transfer data (R/W)
  289.  
  290.               8 Bits of data to be read/written
  291.  
  292.    Address  - $FF02
  293.    Name     - SC
  294.    Contents - SIO control  (R/W)
  295.  
  296.               Bit 7 - Transfer start flag
  297.                       0: Non transfer 
  298.                       1: Start transfer
  299.  
  300.               Bit 0 - Shift Clock
  301.                       0: External Clock
  302.                       1: Internal Clock
  303.  
  304. ------------------------------------------------------------------------------
  305.  
  306.    Address  - $FF04
  307.    Name     - DIV
  308.    Contents - Divider Register (R/W)
  309.  
  310. ------------------------------------------------------------------------------
  311.  
  312.    Address  - $FF05
  313.    Name     - TIMA
  314.    Contents - Timer counter (R/W)
  315.  
  316.               The timer generates an interrupt when it overflows.
  317.  
  318.    Address  - $FF06
  319.    Name     - TMA
  320.    Contents - Timer Modulo (R/W)
  321.  
  322.               When the TIMA overflows, this data will be loaded.
  323.  
  324.    Address  - $FF07
  325.    Name     - TAC
  326.    Contents - Timer Control
  327.  
  328.               Bit 2 - Timer Stop
  329.                       0: Stop Timer
  330.                       1: Start Timer
  331.  
  332.               Bits 1+0 - Input Clock Select
  333.                          00: 4.096 khz
  334.                          01: 262.144 khz
  335.                          10: 65.536 khz
  336.                          11: 16.384 khz
  337.  
  338. ------------------------------------------------------------------------------
  339.  
  340.    Address  - $FF0F
  341.    Name     - IF
  342.    Contents - Interrupt Flag (R/W)
  343.  
  344.               Bit 4: Transition from High to Low of Pin number P10-P13
  345.               Bit 3: Serial I/O transfer end
  346.               Bit 2: Timer Overflow
  347.               Bit 1: LCDC (see STAT)
  348.               Bit 0: V-Blank
  349.  
  350.    Address  - $FFFF
  351.    Name     - IE
  352.    Contents - Interrupt Enable (R/W)
  353.  
  354.               Bit 4: Transition from High to Low of Pin number P10-P13
  355.               Bit 3: Serial I/O transfer end
  356.               Bit 2: Timer Overflow
  357.               Bit 1: LCDC (see STAT)
  358.               Bit 0: V-Blank
  359.  
  360.               0: disable
  361.               1: enable
  362.  
  363.    Address  - XXXX (CPU instruction command)
  364.    Name     - IME
  365.    Content  - Interrupt Master Enable
  366.  
  367.               To prohibit ALL interrupts use CPU instruction DI
  368.               To acknowledge interrupt settings use CPU instruction EI
  369.               DI - Disable Interrupts
  370.               EI - Enable Interrupts
  371.  
  372.    The priority and jump address for the above 5 interrupts are:
  373.  
  374.     Interrupt        Priority        Start Address
  375.  
  376.     V-Blank             1              $0040
  377.     LCDC Status         2              $0048 - Modes 0, 01, 10
  378.                                                LYC=LY coincide (selectable)
  379.  
  380.     Timer Overflow      3              $0050
  381.     Serial Transfer     4              $0058 - when transfer is complete
  382.     Hi-Lo Of Pin        5              $0060
  383.  
  384.     * When more than 1 interrupts occur at the same time ONLY the interrupt
  385.       with the highest priority can be acknowledged.
  386.       When an interrupt is used a '0' should be stored in the IF register
  387.       before the IE register is set.
  388.  
  389.  
  390. -----------------------------------------------------------------------------
  391.  
  392.    Address  - $FF40
  393.    Name     - LCDC
  394.    Contents - LCD Control (R/W)
  395.  
  396.               Bit 7 - LCD Control Operation
  397.                       0: Stop completely (no picture on screen)
  398.                       1: operation
  399.  
  400.               Bit 6 - Window Screen Display Data Select
  401.                       0: $9800-$9BFF
  402.                       1: $9C00-$9FFF
  403.  
  404.               Bit 5 - Window Display
  405.                       0: off
  406.                       1: on
  407.          
  408.               Bit 4 - BG Character Data Select
  409.                       0: $8800-$97FF
  410.                       1: $8000-$8FFF <- Same area as OBJ
  411.  
  412.               Bit 3 - BG Screen Display Data Select
  413.                       0: $9800-$9BFF
  414.                       1: $9C00-$9FFF
  415.            
  416.               Bit 2 - OBJ Construction
  417.                       0: 8*8
  418.                       1: 8*16
  419.  
  420.               Bit 1 - OBJ Display
  421.                       0: off
  422.                       1: on
  423.  
  424.               Bit 0 - BG Display
  425.                       0: off
  426.                       1: on
  427.  
  428.  
  429.    Address  - $FF41
  430.    Name     - STAT
  431.    Contents - LCDC Status   (R/W)
  432.  
  433.               Bits 6-3 - Interrupt Selection By LCDC Status
  434.  
  435.               Bit 6 - LYC=LY Coincidence (Selectable)
  436.               Bit 5 - Mode 10
  437.               Bit 4 - Mode 01
  438.               Bit 3 - Mode 00
  439.                       0: Non Selection
  440.                       1: Selection
  441.  
  442.               Bit 2 - Coincidence Flag
  443.                       0: LYC not equal to LCDC LY
  444.                       1: LYC = LCDC LY
  445.  
  446.               Bit 1-0 - Mode Flag
  447.                         00: Entire Display Ram can be accessed
  448.                         01: During V-Blank
  449.                         10: During Searching OAM-RAM
  450.                         11: During Transfering Data to LCD Driver
  451.  
  452.  
  453.      STAT shows the current status of the LCD controller.
  454.      Mode 00: When the flag is 00 it is the H-Blank period and the CPU can
  455.               access the display RAM ($8000-$9FFF)
  456.               When it is not equal the display ram is being used by the
  457.               LCD controller
  458.  
  459.      Mode 01: When the flag is 01 it is the V-Blank period and the CPU can
  460.               access the display RAM ($800-$9FFF)
  461.  
  462.      Mode 10: When the flag is 10 then the OAM is being used ($FE00-$FE90)
  463.               The CPU cannot access the OAM during this period
  464.      
  465.      Mode 11: When the flag is 11 both the OAM and CPU are being used.
  466.               The CPU cannot access either during this period
  467.  
  468. -----------------------------------------------------------------------------
  469.  
  470.    Address  - $FF42
  471.    Name     - SCY
  472.    Contents - Scroll Y   (R/W)
  473.  
  474.               8 Bit value $00-$FF to scroll BG Y screen position
  475.  
  476.    Address  - $FF43
  477.    Name     - SCX
  478.    Contents - Scroll X   (R/W)
  479.  
  480.               8 Bit value $00-$FF to scroll BG X screen position
  481.  
  482.    Address  - $FF44
  483.    Name     - LY
  484.    Contents - LCDC Y-Coordinate (R)
  485.  
  486.             The LY indicates the vertical line to which the present data
  487.             is transferred to the LCD Driver
  488.             The LY can take on any value between 0 through 153. The values
  489.             between 144 and 153 indicate the V-Blank period. Writing will
  490.             reset the counter.
  491.  
  492.             This is just a RASTER register. The current line is thrown
  493.             into here. But since there are no RASTERS on an LCD display.....
  494.             it's called the LCDC Y-Coordinate.
  495.  
  496.    Address  - $FF45
  497.    Name     - LYC
  498.    Contents - LY Compare  (R/W)
  499.  
  500.             The LYC compares itself with the LY. If the values are the same
  501.             it causes the STAT to set the coincident flag.
  502.  
  503.    Address  - $FF47
  504.    Name     - BGP
  505.    Contents - BG Palette Data  (W)
  506.  
  507.               Bit 7-6 - Data for Dot Data 11
  508.               Bit 5-4 - Data for Dot Data 10
  509.               Bit 3-2 - Data for Dot Data 01
  510.               Bit 1-0 - Data for Dot Data 00
  511.  
  512.               This selects the shade of gray you what for your BG pixel.
  513.               Since each pixel uses 2 bits, the corresponding shade will
  514.               be selected from here. The Background Color (00) lies at
  515.               Bits 1-0, just put a value from 0-$3 to change the color.
  516.  
  517.    Address  - $FF48
  518.    Name     - OBP0
  519.    Contents - Object Palette 0 Data (W)
  520.  
  521.               This selects the colors for sprite palette 0.
  522.               It works exactly as BGP ($FF47).
  523.               See BGP for details.
  524.  
  525.    Address  - $FF49
  526.    Name     - OBP1
  527.    Contents - Object Palette 1 Data (W)
  528.  
  529.               This Selects the colors for sprite palette 1.
  530.               It works exactly as BGP ($FF47).
  531.               See BGP for details.
  532.  
  533.  
  534.    Address  - $FF4A
  535.    Name     - WY
  536.    Contents - Window Y Position  (R/W)
  537.  
  538.               0 <= WY <= 143
  539.  
  540.               WY must be greater than or equal to 0 and must be less than
  541.               or equal to 143.
  542.  
  543.    Address  - $FF4B
  544.    Name     - WX
  545.    Contents - Window X Position  (R/W)
  546.  
  547.               7 <= WX <= 166
  548.  
  549.               WX must be greater than or equal to 7 and must be less than
  550.               or equal to 166.
  551.  
  552.  
  553.               Lets say WY = 80 and WX = 80.
  554.               The window would be positioned as so:
  555.  
  556.                0                  80                          159
  557.                _________________________________________________
  558.             0 |                   |                             |
  559.               |                   |                             |
  560.               |                   |                             |
  561.               |                   |                             |
  562.               |                   |                             |
  563.               |                   |                             |
  564.               |                   |                             |
  565.               |                   |                             |
  566.               |                   |                             |
  567.               |                   |80                           |
  568.            80 |-------------------+-----------------------------|
  569.               |                80 |                             |
  570.               |                   |                             |
  571.               |                   |      Window Display         |
  572.               |                   |                             |
  573.               |                   |                             |
  574.               |                   |           Here              |
  575.               |                   |                             |
  576.               |                   |                             |
  577.               |                   |                             |
  578.           143 |___________________|_____________________________|
  579.  
  580.  
  581.           OBJ Characters (Sprites) can still enter the window
  582.           So can BG characters
  583.  
  584. -----------------------------------------------------------------------------
  585.  
  586.    Address  - $FF46
  587.    Name     - DMA
  588.    Contents - DMA Transfer and Start Address (W)
  589.  
  590.    The DMA Transfer (40*28 bit) from internal ROM or RAM ($0000-$F19F)
  591.    to the OAM (address $FE00-$FE9F) can be performed. It takes 160 nano-seconds
  592.    for the transfer.
  593.  
  594.    40*28 bit = #140  or #$8C.  As you can see, it only transfers $8C bytes
  595.    of data. OAM data is $A0 bytes long, from $0-$9F.
  596.  
  597.    But if you examine the OAM data you see that 4 bits are not in use.
  598.    
  599.    40*32 bit = #$A0, but since 4 bits for each OAM is not used it's
  600.    40*28 bit.
  601.  
  602.    It transfers all the OAM data to OAM RAM.
  603.  
  604.    The DMA transfer start address can be designated every $100 from address
  605.    $0000-$F100.   That means $0000, $0100, $0200, $0300.... 
  606.  
  607.    Example program:
  608.       DI             <- Disable Interrupt
  609.       LD A,#$04      <- transfer data from $0400
  610.       LD ($FF46),A   <- put A into DMA registers
  611.       LD A,#40       <- #40 is the value to wait for. we need to wait 160
  612. Wait:                <- nano seconds
  613.       DEC A          <- decrease A by 1
  614.       JR NZ,Wait     <- branch if Not Zero to Wait
  615.       EI             <- Enable Interrupt
  616.       RET            <- RETurn from sub-routine
  617.  
  618. -----------------------------------------------------------------------------
  619.  
  620.    Address  - $FF10
  621.    Name     - NR 10
  622.    Contents - Sound Mode 1 register, Sweep register (R/W)
  623.  
  624.               Bit 6-4 - Sweep Time
  625.               Bit 3 - Sweep Increase/Decrease
  626.                       0: Addition    (frequency increases)
  627.                       1: Subtraction (frequency increases)
  628.               Bit 2-0 - Number of sweep shift (# 0-7)
  629.  
  630.               Sweep Time:
  631.  
  632.               000: sweep off
  633.               001: 7.8 ms
  634.               010: 15.6 ms
  635.               011: 23.4 ms
  636.               100: 31.3 ms
  637.               101: 39.1 ms
  638.               110: 46.9 ms
  639.               111: 54.7 ms
  640.  
  641.  
  642.    Address  - $FF11
  643.    Name     - NR 11
  644.    Contents - Sound Mode 1 register, Sound length/Wave pattern duty (R/W)
  645.               
  646.               Only Bits 7-6 can be read.
  647.  
  648.               Bit 7-6 - Wave Pattern Duty
  649.               Bit 5-0 - Sound length data (# 0-63)
  650.  
  651.               Wave Duty:
  652.               
  653.               00: 12.5%
  654.               01: 25%
  655.               10: 50%
  656.               11: 75%
  657.  
  658.    Address  - $FF12
  659.    Name     - NR 12
  660.    Contents - Sound Mode 1 register, Envelope (R/W)
  661.  
  662.               Bit 7-4 - Initial value of envelope
  663.               Bit 3 - Envelope UP/DOWN
  664.                       0: Decrease
  665.                       1: Range of increase
  666.               Bit 2-0 - Number of envelope sweep (# 0-7)
  667.               
  668.               Initial value of envelope is from %0000 to %1111
  669.  
  670.    Address  - $FF13
  671.    Name     - NR 13
  672.    Contents - Sound Mode 1 register, Frequency lo (W)
  673.  
  674.               lower 8 bits of 11 bit frequency.
  675.               Next 3 bit or in NR 14 ($FF14)
  676.  
  677.    Address  - $FF14
  678.    Name     - NR 14
  679.    Contents - Sound Mode 1 register, Frequency hi (R/W)
  680.  
  681.               Only Bit 6 can be read.
  682.  
  683.               Bit 7 - Initial (when set, sound restarts)
  684.               Bit 6 - Counter/consecutive selection
  685.               Bit 2-0 - Frequency's higher 3 bits
  686.  
  687.    Address  - $FF16
  688.    Name     - NR 21
  689.    Contents - Sound Mode 2 register, Sound Length; Wave Pattern Duty (R/W)
  690.  
  691.               Only bits 7-6 can be read.
  692.  
  693.               Bit 7-6 - Wave pattern duty
  694.               Bit 5-0 - Sound length (# 0-63)
  695.  
  696.    Address  - $FF17
  697.    Name     - NR 22
  698.    Contents - Sound Mode 2 register, envelope (R/W)
  699.  
  700.               Bit 7-4 - Initial envelope value
  701.               Bit 3 - Envelope UP/DOWN
  702.                       0: decrease
  703.                       1: range of increase
  704.               Bit 2-0 - Number of envelope step (# 0-7)
  705.  
  706.    
  707.    Address  - $FF18
  708.    Name     - NR 23
  709.    Contents - Sound Mode 2 register, frequency lo data (W)
  710.  
  711.               Frequency's lower 8 bits of 11 bit data
  712.               Next 3 bits are in NR 14 ($FF19)
  713.  
  714.    Address  - $FF19
  715.    Name     - NR 24
  716.    Contents - Sound Mode 2 register, frequency hi data (R/W)
  717.  
  718.               Only bit 6 can be read.
  719.  
  720.               Bit 7 - Initial
  721.               Bit 6 - Counter/consecutive selection
  722.               Bit 2-0 - Frequency's higher 3 bits
  723.  
  724.    Address  - $FF1A
  725.    Name     - NR 30
  726.    Contents - Sound Mode 3 register, Sound on/off (R/W)
  727.           
  728.               Only bit 7 can be read
  729.  
  730.               Bit 7 - Sound OFF
  731.                       0: Sound 3 output stop
  732.                       1: Sound 3 output OK
  733.  
  734.    Address  - $FF1B
  735.    Name     - NR 31
  736.    Contents - Sound Mode 3 register, sound length (R/W)
  737.  
  738.               Bit 7-0 - Sound length
  739.  
  740.    Address  - $FF1C
  741.    Name     - NR 32
  742.    Contents - Sound Mode 3 register, Select output level
  743.           
  744.               Only bits 6-5 can be read
  745.  
  746.               Bit 6-5 - Select output level
  747.                         00: Mute
  748.                         01: Produce Wave Pattern RAM Data as it is 
  749.                             (4 bit length)
  750.                         10: Produce Wave Pattern RAM data shifted once to the
  751.                             RIGHT (1/2)  (4 bit length)
  752.                         11: Produce Wave Pattern RAM data shifted twice to the
  753.                             RIGHt (1/4)  (4 bit length)
  754.  
  755.        * - Wave Pattern RAM is located from $FF30-$FF3f
  756.  
  757.    Address  - $FF1D
  758.    Name     - NR 33
  759.    Contents - Sound Mode 3 register, frequency's lower data (W)
  760.  
  761.               Lower 8 bits of an 11 bit frequency
  762.  
  763.    Address  - $FF1E
  764.    Name     - NR 34
  765.    Contents - Sound Mode 3 register, frequency's higher data (R/W)
  766.  
  767.               Only bit 6 can be read.
  768.  
  769.               Bit 7 - Initial flag
  770.               Bit 6 - Counter/consecutive flag
  771.               Bit 2-0 - Frequency's higher 3 bits
  772.  
  773.  
  774.  
  775.    Address  - $FF20
  776.    Name     - NR 41
  777.    Contents - Sound Mode 4 register, sound length (R/W)
  778.  
  779.               Bit 5-0 - Sound length data (# 0-63)
  780.  
  781.   
  782.    Address  - $FF21
  783.    Name     - NR 42
  784.    Contents - Sound Mode 4 register, envelope (R/W)
  785.  
  786.               Bit 7-4 - Initial value of envelope
  787.               Bit 3 - Envelope UP/DOWN
  788.                       0: decrease
  789.                       1: range of increase
  790.               Bit 2-0 - number of envelope step (# 0-7)
  791.  
  792.    Address  - $FF22
  793.    Name     - NR 43
  794.    Contents - Sound Mode 4 register, polynomial counter (R/W)
  795.  
  796.               Bit 7-4 - Selection of the shift clock frequency of the
  797.                         polynomial counter
  798.               Bit 3 - Selection of the polynomial counter's step
  799.               Bit 2-0 - Selection of the dividing ratio of frequencies
  800.  
  801.               Selection of the dividing ratio of frequencies:
  802.               000: f * 1/2^3 * 2
  803.               001: f * 1/2^3 * 1
  804.               010: f * 1/2^3 * 1/2
  805.               011: f * 1/2^3 * 1/3
  806.               100: f * 1/2^3 * 1/4
  807.               101: f * 1/2^3 * 1/5
  808.               110: f * 1/2^3 * 1/6
  809.               111: f * 1/2^3 * 1/7           f = 4.194304 Mhz
  810.  
  811.               Selection of the polynomial counter step:
  812.               0: 15 steps
  813.               1: 7 steps
  814.   
  815.               Selection of the shift clock frequency of the polynomial
  816.               counter:
  817.  
  818.               0000: dividing ratio of frequencies * 1/2
  819.               0001: dividing ratio of frequencies * 1/2^2
  820.               0010: dividing ratio of frequencies * 1/2^3
  821.               0011: dividing ratio of frequencies * 1/2^4
  822.                     :                          :
  823.                     :                          : 
  824.                     :                          :
  825.               0101: dividing ratio of frequencies * 1/2^14
  826.               1110: prohibited code
  827.               1111: prohibited code
  828.  
  829.    Address  - $FF30
  830.    Name     - NR 30
  831.    Contents - Sound Mode 4 register, counter/consecutive; inital (R/W)
  832.  
  833.               Only bit 6 can be read.
  834.   
  835.               Bit 7 - Inital
  836.               Bit 6 - Counter/consecutive selection                    
  837.  
  838.  
  839.    Address  - $FF24
  840.    Name     - NR 50
  841.    Contents - Channel control / ON-OFF / Volume (R/W)
  842.  
  843.               Bit 7 - Vin->SO2 ON/OFF
  844.               Bit 6-4 - SO2 output level (volume) (# 0-7)
  845.               Bit 3 - Vin->SO1 ON/OFF
  846.               Bit 2-0 - SO1 output level (volume) (# 0-7)
  847.  
  848.               Vin->SO1 (Vin->SO2)
  849.               
  850.               By synthesizing the sound from sound 1 through 4, the voice
  851.               input from Vin terminal is put out.
  852.               0: no output
  853.               1: output OK
  854.  
  855.     Address  - $FF25
  856.     Name     - NR 51
  857.     Contents - Selection of Sound output terminal (R/W)
  858.  
  859.                Bit 7 - Output sound 4 to SO2 terminal
  860.                Bit 6 - Output sound 3 to SO2 terminal
  861.                Bit 5 - Output sound 2 to SO2 terminal
  862.                Bit 4 - Output sound 1 to SO2 terminal
  863.                Bit 3 - Output sound 4 to SO1 terminal
  864.                Bit 2 - Output sound 3 to SO1 terminal
  865.                Bit 1 - Output sound 2 to SO1 terminal
  866.                Bit 0 - Output sound 0 to SO1 terminal
  867.  
  868.     Address  - $FF26
  869.     Name     - NR 52
  870.     Contents - Sound on/off (R/W)
  871.  
  872.                Only Bit 7, 3-0 can be read.
  873.  
  874.                Bit 7 - All sound on/off
  875.                        0: stop all sound circuits
  876.                        1: operate all sound circuits
  877.                Bit 3 - Sound 4 ON flag
  878.                Bit 2 - Sound 3 ON flag
  879.                Bit 1 - Sound 2 ON flag
  880.                Bit 0 - Sound 1 ON flag
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893. 3. Ok, so the Game Boy runs on a Z80, and that's an 8 bit processor...
  894.    So how is it possible for an 8 bit processor to access 4 Mbits?
  895.    -------------------------------------------------------------------
  896.  
  897.    Simple! Bank switching! If you examine the graphic diagram Address1.xxx
  898.    you will see some very strange stuff!
  899.  
  900.    The Z80 can only work with 16 bit addresses $0-$FFFF
  901.  
  902.    So to access the other data you must trick the machine into pointing
  903.    to another piece of memory.
  904.    
  905.    ROM is located from $0000 - $7FFF, RAM is from $8000-$FFFF
  906.  
  907.    All game programs are ROM so we know it is from $0000-$7FFF
  908.  
  909.    But the Game Boy has a fixed memory area from $0000-$3FFF; when you 
  910.    access it, it will always be BANK 0. It is called the FIXED HOME ADDRESS.
  911.  
  912.    That means the only other ROM addresses available are $4000-$7FFF.
  913.  
  914.    Bank 0 is read by the CPU as being at $0000-$3FFF
  915.    Bank 1 is read by the CPU as being at $4000-$7FFF
  916.    Bank 2 is read by the CPU as being at $4000-$7FFF
  917.    Bank 3 is read by the CPU as being at $4000-$7FFF
  918.  
  919.    See the pattern? Only the FIXED HOME ADDRESS has it's own special
  920.    location.
  921.  
  922.    Banks and addresses starting at $4000 is called the CPU address.
  923.  
  924.    CPU Address $014000 is actually Bank #$01 address $4000
  925.  
  926.    CPU Address $014000 is equal to ROM address (offset) $004000
  927.  
  928.    CPU Address $024000 is equal to ROM address (offset) $008000
  929.  
  930.    CPU Address $044000 is equal to ROM address (offset) $010000
  931.  
  932.    The CPU uses the CPU ADDRESS.
  933.  
  934.    How to switch BANKS:
  935.  
  936.    Using MBC1 (Memory Bank Controller 1)
  937.  
  938.    Writing to ROM Address (CPU FIXED HOME ADDRESS) $2000-$3FFF
  939.    the ROM bank can be selected. The values are from #$01-#$0F
  940.  
  941.    LD A,#$01
  942.    LD ($2000),A     <- this selects ROM BANK #$01
  943.  
  944.  
  945.    Writing to ROM Address (CPU FIXED HOME ADDRESS) $4000-$5FFF
  946.    the RAM bank can be selected. The values are from #$00-#$03
  947.  
  948.    LD A,#$03
  949.    LD ($4000),A     <- this select RAM BANK #$03
  950.  
  951.    Using MBC2 (Memory Bank Controller 2)
  952.  
  953.    Writing to ROM Address (CPU FIXED HOME ADDRESS) $2100-$21FF
  954.    the ROM bank can be select. The values are from #$01-#$0F
  955.    
  956.                        
  957.             
  958.  
  959.  
  960.  
  961.   
  962. 4. The SNES and Genesis has an some cartridge information in the ROM.
  963.    Does the Game Boy have some info, too?
  964.    ------------------------------------------------------------------
  965.  
  966.    Sure, why not?!
  967.  
  968.    The Internal Info block begins at $100 and it's format is as follows:
  969.  
  970.    $100-$101 - 00 C3  (2 bytes)
  971.    $102-$102 - Lo Hi  (Start Address for Game, usually $150 it would be written
  972.                        as 50 01)
  973.    $100-$133 - Nintendo Character Area, if this does not exist the game
  974.                will not run!
  975.  
  976. 000100: 00 C3 50 01 CE ED 66 66 CC 0D 00 0B 03 73 00 83
  977. 000110: 00 0C 00 0D 00 08 11 1F 88 89 00 0E DC CC 6E E6
  978. 000120: DD DD D9 99 BB BB 67 63 6E 0E EC CC DD DC 99 9F
  979. 000130: BB B9 33 3E
  980.  
  981.    $134-$143 - Title Registration Area (title of the game in ASCII)
  982.    $144-$146 - NOT USED
  983.    $147 - CARTRIDGE TYPE 
  984.           0 - ROM ONLY
  985.           1 - ROM+MBC1
  986.           2 - ROM+MBC1+RAM
  987.           3 - ROM+MBC1+RAM+BATTERY
  988.           5 - ROM+MBC2
  989.           6 - ROM+MBC2+BATTERY
  990.    
  991.   $148 - ROM SIZE
  992.          0 - 256kbit
  993.          1 - 512kbit
  994.          2 - 1M-Bit
  995.          3 - 2M-Bit
  996.          4 - 4M-Bit
  997.  
  998.   $149 - RAM SIZE
  999.          0 - NONE
  1000.          1 - 16kbit
  1001.          2 - 64kbit
  1002.          3 - 256kbit
  1003.  
  1004.   $14A-$14B - Maker Code - 2 bytes
  1005.   $14C - Version Number
  1006.   $14D - Complement Check
  1007.   $14E-$14F - Checksum HI-LO (2 bytes in Big Endian format, high byte first)
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014. 5. Are there any public development tools available for the Game Boy?
  1015.    ------------------------------------------------------------------
  1016.  
  1017.    I don't know of many Z80 cross-assemblers available, or if they support
  1018.    instructions like SWAP A, or LD (HLI),A.
  1019.    It could be possible to use a generic Z80 assembler and to write
  1020.    the non-standard instructions by entering the op-code as a Declared Byte.
  1021.  
  1022.    The only publicly available disassembler I know of is the one I made
  1023.    for the Amiga. It is included in a SNES 65816/SPC700 disassembler
  1024.    and supports non-standard Z80 op-codes. The multi-processor disassembler
  1025.    is called Super Magic Disassembler, it's current release version
  1026.    is 1.4 and can be found on bulletin boards world-wide.
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032. 6. Are there any Game Boy Emulators available?
  1033.    -------------------------------------------
  1034.  
  1035.    NO! NO! NONONONO! The only SO-CALLED Emulator was on the AMIGA but was
  1036.    a BIG FAKE! If you got it to work, it only played TETRIS.
  1037.    It did NOT emulate a Game Boy. It was just a version of Tetris
  1038.    played in a graphic rendition of a Game Boy.
  1039.    According to some FAQ floating around the Emulator is called Toy-Boy
  1040.    and it was made by Argonaut Software.   Come on! Argonaut has 1 Amiga, 
  1041.    which was used for graphics.. but since they've gotten a Silicon Graphics
  1042.    Workstation I highly doubt they use it anymore!
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048. 7. What about Super-Game Boy info? What are it's Specs?
  1049.    ----------------------------------------------------
  1050.  
  1051.    What am I, Master Brain of the World? I don't have info on everything! :)
  1052.  
  1053.  
  1054.  
  1055.  
  1056. 8. Wow! This was some cool info! Now I can sleep at night!
  1057.    -------------------------------------------------------
  1058.  
  1059.    Yeah! Now you can stop bugging me with all your questions!
  1060.  
  1061.  
  1062.  
  1063.